Skip to content

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Sep 29, 2025

This emits the same attributes we place on allocator declarations on the definitions in the allocator shim as well. This complements #146766, which added the attribute for #[global_allocator] definitions. Emitting the attributes on the definitions ensures that they cannot be lost of the allocator shim participates in LTO.

See #145995 for context, though that one was about #[global_allocator]. I'm not sure whether this can occur with the allocator shim as well or not, but better safe than sorry.

I'm not sure whether there is any good way to test this, as the allocator shim is not part of --emit=llvm-ir. I've verified this locally by inspecting the bitcode produced by -C save-temps.

r? @bjorn3

This emits the same attributes we place on allocator declarations
(and allocator definitions using `#[global_allocator]`) on the
definitions in the allocator shim as well, making sure that the
attributes are not lost if the allocator shim participates in LTO.
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 29, 2025
@bjorn3
Copy link
Member

bjorn3 commented Sep 29, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 29, 2025

📌 Commit af8fd78 has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 29, 2025
Emit allocator attributes for allocator shim

This emits the same attributes we place on allocator declarations on the definitions in the allocator shim as well. This complements rust-lang#146766, which added the attribute for `#[global_allocator]` definitions. Emitting the attributes on the definitions ensures that they cannot be lost of the allocator shim participates in LTO.

See rust-lang#145995 for context, though that one was about `#[global_allocator]`. I'm not sure whether this can occur with the allocator shim as well or not, but better safe than sorry.

I'm not sure whether there is any good way to test this, as the allocator shim is not part of `--emit=llvm-ir`. I've verified this locally by inspecting the bitcode produced by `-C save-temps`.

r? `@bjorn3`
bors added a commit that referenced this pull request Sep 29, 2025
Rollup of 6 pull requests

Successful merges:

 - #143613 (Fix backtraces with `-C panic=abort` on linux; emit unwind tables by default)
 - #146937 (std: implement `hostname`)
 - #147040 (mbe: macro_check: Fix function comments referencing non-existent parameters)
 - #147131 (Use MirPatch in simplify_branches.)
 - #147133 (Remove one loop in `extract_cfg_from_attrs`)
 - #147150 (Emit allocator attributes for allocator shim)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Sep 29, 2025
Rollup of 5 pull requests

Successful merges:

 - #146937 (std: implement `hostname`)
 - #147040 (mbe: macro_check: Fix function comments referencing non-existent parameters)
 - #147131 (Use MirPatch in simplify_branches.)
 - #147133 (Remove one loop in `extract_cfg_from_attrs`)
 - #147150 (Emit allocator attributes for allocator shim)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3799799 into rust-lang:master Sep 30, 2025
10 checks passed
rust-timer added a commit that referenced this pull request Sep 30, 2025
Rollup merge of #147150 - nikic:alloc-shim-attributes, r=bjorn3

Emit allocator attributes for allocator shim

This emits the same attributes we place on allocator declarations on the definitions in the allocator shim as well. This complements #146766, which added the attribute for `#[global_allocator]` definitions. Emitting the attributes on the definitions ensures that they cannot be lost of the allocator shim participates in LTO.

See #145995 for context, though that one was about `#[global_allocator]`. I'm not sure whether this can occur with the allocator shim as well or not, but better safe than sorry.

I'm not sure whether there is any good way to test this, as the allocator shim is not part of `--emit=llvm-ir`. I've verified this locally by inspecting the bitcode produced by `-C save-temps`.

r? ``@bjorn3``
@rustbot rustbot added this to the 1.92.0 milestone Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants